Dynomotion

Group: DynoMotion Message: 9503 From: tapiolarikka Date: 5/19/2014
Subject: Disabled axis drifts?
Hi Tom!

I have (in my both milling machines) small axis drift whenever axis gets disabled.

I figured I get rid of this by wiring the amplifier drive permits to an output( all 3 axis to same output)

and adding this to the init for(;;) loop:

SetStatebit(DrivePermit)=(Enabled(0)+Enabled(1)+Enabled(2))/3;

For some reason the compiler did not accept this?Where did I go wrong?

The idea with above was that if any of the axes is disabled the division would return 0 due to C truncating

Rgds,
Tapio


Group: DynoMotion Message: 9505 From: Moray Cuthill Date: 5/19/2014
Subject: Re: Disabled axis drifts?
Tapio,
 
SetStateBit(xxx) has to equal a boolean i.e. true or false value.
What you have is a mix of boolean values, which are then divided by an integer which if the compiler didn't reject, could result in either a float, integer or boolean result depending on how the internal functions handle the calculation/variables.
 
What you really need is someway of establishing a boolean result, something like-
if(Enabled(0) && Enabled(1) && Enabled(2)){
   SetStateBit(DrivePermit)=true;
} else {
   SetStateBit(DirvePermit)=false;
}
 
The if statement checks that all enables are true, and activates DrivePermit, and should any enables not be true, disables DrivePermit.
 
Moray


On Mon, May 19, 2014 at 9:55 PM, tapio.larikka@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi Tom!

I have (in my both milling machines) small axis drift whenever axis gets disabled.

I figured I get rid of this by wiring the amplifier drive permits to an output( all 3 axis to same output)

and adding this to the init for(;;) loop:

SetStatebit(DrivePermit)=(Enabled(0)+Enabled(1)+Enabled(2))/3;

For some reason the compiler did not accept this?Where did I go wrong?

The idea with above was that if any of the axes is disabled the division would return 0 due to C truncating

Rgds,
Tapio



Group: DynoMotion Message: 9506 From: Tom Kerekes Date: 5/19/2014
Subject: Re: Disabled axis drifts?
Hi Tapio,

I think the idea is correct but the syntax is wrong.  && is the logical "and" operator in C.

Try:

        // if all axes channels are enabled then enable the amps
        if (ch0->Enable && ch1->Enable && ch2->Enable)
            SetBit(DrivePermit);
        else
            ClearBit(DrivePermit);

or alternate ways more along your thinking might be:
(SetStateBit requires two parameters - which bit and the state.  It is not assignable)

        SetStateBit(DrivePermit, ch0->Enable && ch1->Enable && ch2->Enable);

or this (not recommended but may also work)

        SetStateBit(DrivePermit, (ch0->Enable + ch1->Enable + ch2->Enable)/3);

HTH
Regards
TK

Group: DynoMotion Message: 9507 From: Tom Kerekes Date: 5/19/2014
Subject: Re: Disabled axis drifts?
Hi Tapio,

I think the idea is correct but the syntax is wrong.  && is the logical "and" operator in C.

Try:

        // if all axes channels are enabled then enable the amps
        if (ch0->Enable && ch1->Enable && ch2->Enable)
            SetBit(DrivePermit);
        else
            ClearBit(DrivePermit);

or alternate ways more along your thinking might be:
(SetStateBit requires two parameters - which bit and the state.  It is not assignable)

        SetStateBit(DrivePermit, ch0->Enable && ch1->Enable && ch2->Enable);

or this (not recommended but may also work)

        SetStateBit(DrivePermit, (ch0->Enable + ch1->Enable + ch2->Enable)/3);

HTH
Regards
TK

Group: DynoMotion Message: 9508 From: Tapio Larikka Date: 5/19/2014
Subject: Re: Disabled axis drifts?

Hi Tom/Moray,
 
Thank you for the example. I'll try them tomorrow.
 
My thinking to use the setstatebit is trying to avoid if/then when possible, I've noticed that I'll easily get lost with them :)
 
Rgds,
Tapio
 
----- Original Message -----
Sent: Tuesday, May 20, 2014 12:17 AM
Subject: Re: [DynoMotion] Disabled axis drifts?

 

Hi Tapio,

I think the idea is correct but the syntax is wrong.  && is the logical "and" operator in C.

Try:

        // if all axes channels are enabled then enable the amps
        if (ch0->Enable && ch1->Enable && ch2->Enable)
            SetBit(DrivePermit);
        else
            ClearBit(DrivePermit);

or alternate ways more along your thinking might be:
(SetStateBit requires two parameters - which bit and the state.  It is not assignable)

        SetStateBit(DrivePermit, ch0->Enable && ch1->Enable && ch2->Enable);

or this (not recommended but may also work)

        SetStateBit(DrivePermit, (ch0->Enable + ch1->Enable + ch2->Enable)/3);

HTH
Regards
TK